﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ThreadTest
{
    public class ThreadStartDemo
    {
        public static void ShowMessage()
        {
            string message = string.Format("Async threadId is :{0}",
                                            Thread.CurrentThread.ManagedThreadId);
            Console.WriteLine(message);

            for (int n = 0; n < 10; n++)
            {
                Thread.Sleep(300);
                Console.WriteLine("The number is:" + n.ToString());
            }
        }


        public static void ThreadStartMethod()
        {
            Console.WriteLine("Main threadId is:" +
                                Thread.CurrentThread.ManagedThreadId);
            Thread thread = new Thread(new ThreadStart(ShowMessage));
            thread.Start();
            Console.WriteLine("Do something ..........!");
            Console.WriteLine("Main thread working is complete!");
        }

    }
}
